﻿namespace UnityEditor.Controls.MenuSearchControl
{
    using System.Collections.Generic;
    using System.Windows;
    using System.Windows.Controls;

    public static class Extensions
    {
        public static IEnumerable<object> GetMenuParents(this FrameworkElement element)
        {
            var parents = new List<object>();

            if (element.Parent is MenuItem)
            {
                parents.Add(element.Parent);
                parents.AddRange((element.Parent as MenuItem).GetMenuParents());
            }

            return parents;
        }
    }
}
